-
-
Notifications
You must be signed in to change notification settings - Fork 7
Update plugins.json fetch URL to main branch #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughUpdated the plugins manifest fetch URL in src/getPluginsJson.ts from plugin_api_v2/plugins.json to main/plugins.json. No changes to types, control flow, caching, or error handling. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Possibly related PRs
Suggested labels
Suggested reviewers
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
src/getPluginsJson.ts
(1 hunks)
🔇 Additional comments (1)
src/getPluginsJson.ts (1)
26-26
: Verified plugin manifest URLs are live
Both the primary and fallback endpoints return HTTP 200 and expose the expected JSON structure:
- main/plugins.json keys: Author, Description, E-tag, ID, Language, Name, UrlDownload, UrlSourceCode, Version, Website
- plugin_api_v2/plugins.json keys: Author, DateAdded, Description, ID, IcoPath, Language, LatestReleaseDate, Name, UrlDownload, UrlSourceCode, Version, Website
All set to merge.
export async function getPluginsJson() { | ||
if (!cachedData?.length) { | ||
const data: FlowPlugin[] = await fetch("https://raw.githubusercontent.com/Flow-Launcher/Flow.Launcher.PluginsManifest/plugin_api_v2/plugins.json").then(v => v.json()); | ||
const data: FlowPlugin[] = await fetch("https://raw.githubusercontent.com/Flow-Launcher/Flow.Launcher.PluginsManifest/main/plugins.json").then(v => v.json()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Harden the manifest fetch (ok-check, timeout, and safe fallback).
If main/plugins.json
isn’t live yet or GitHub responds non-200/transiently, .json()
will throw and break the build. Add res.ok
handling, a short timeout, and a fallback to the previous manifest path.
- const data: FlowPlugin[] = await fetch("https://raw.githubusercontent.com/Flow-Launcher/Flow.Launcher.PluginsManifest/main/plugins.json").then(v => v.json());
+ const urls = [
+ // Allow override via env during migration or local testing
+ (import.meta as any)?.env?.PLUGINS_MANIFEST_URL
+ ?? process.env.PLUGINS_MANIFEST_URL
+ ?? "https://raw.githubusercontent.com/Flow-Launcher/Flow.Launcher.PluginsManifest/main/plugins.json",
+ // Fallback to old location (remove once migration is fully done)
+ "https://raw.githubusercontent.com/Flow-Launcher/Flow.Launcher.PluginsManifest/plugin_api_v2/plugins.json",
+ ].filter(Boolean) as string[];
+
+ const controller = new AbortController();
+ const timeout = setTimeout(() => controller.abort(), 10_000);
+ let data: FlowPlugin[] | undefined;
+ for (const url of urls) {
+ try {
+ const res = await fetch(url, {
+ signal: controller.signal,
+ headers: { accept: "application/json" },
+ });
+ if (!res.ok) continue;
+ data = await res.json();
+ break;
+ } catch {
+ // try next URL
+ }
+ }
+ clearTimeout(timeout);
+ if (!data) {
+ throw new Error("Failed to fetch plugins manifest from any known URL.");
+ }
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const data: FlowPlugin[] = await fetch("https://raw.githubusercontent.com/Flow-Launcher/Flow.Launcher.PluginsManifest/main/plugins.json").then(v => v.json()); | |
// Hardened manifest fetch: support env override, timeout, ok-check, and fallback URL | |
const urls = [ | |
// Allow override via env during migration or local testing | |
(import.meta as any)?.env?.PLUGINS_MANIFEST_URL | |
?? process.env.PLUGINS_MANIFEST_URL | |
?? "https://raw.githubusercontent.com/Flow-Launcher/Flow.Launcher.PluginsManifest/main/plugins.json", | |
// Fallback to old location (remove once migration is fully done) | |
"https://raw.githubusercontent.com/Flow-Launcher/Flow.Launcher.PluginsManifest/plugin_api_v2/plugins.json", | |
].filter(Boolean) as string[]; | |
const controller = new AbortController(); | |
const timeout = setTimeout(() => controller.abort(), 10_000); | |
let data: FlowPlugin[] | undefined; | |
for (const url of urls) { | |
try { | |
const res = await fetch(url, { | |
signal: controller.signal, | |
headers: { accept: "application/json" }, | |
}); | |
if (!res.ok) continue; | |
data = await res.json(); | |
break; | |
} catch { | |
// try next URL on error (including timeout) | |
} | |
} | |
clearTimeout(timeout); | |
if (!data) { | |
throw new Error("Failed to fetch plugins manifest from any known URL."); | |
} |
🤖 Prompt for AI Agents
In src/getPluginsJson.ts around line 26, the fetch call lacks ok-checks, a
timeout, and a fallback; update it to use an AbortController with a short
timeout (e.g., 3s), await fetch and verify res.ok before calling res.json(), and
if the first request fails (network error, non-ok, or timeout) attempt the
previous manifest URL (e.g., the same raw GitHub path but using the prior
branch/path such as "master/plugins.json"); if both attempts fail, handle
gracefully by returning an empty array (or a safe default) and log a warning
instead of letting .json() throw and break the build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, got to this before I did 😆. Thank you
Is it okay to merge it immediately? Won't that stop updates for all plugins for all users until v2.0.0 is released? Edit: Sorry, got a little mixed up. Still, won't that prevent plugin updates from displaying on the website until v2.0.0 is released? |
This is following this change in the main repository: Flow-Launcher/Flow.Launcher#3933. This PR should be merged after the full switch to
main
branch in PluginsManifest repository.